<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>简单实现</title>
  <script src="/lib/echarts.min.js"></script>
</head>

<body>
  <div id="myEharts" style="width:600px;height:400px"></div>
  <script>
    const myCharts = echarts.init(document.getElementById('myEharts'))
    const option = {
      title: {
        text: 'echarts入门实例',
        link: 'https://www.baidu.com',
        textStyle: {
          color: '#ff3040',
          fontStyle: 'italic'
        }
      },
      tooltip: {},
      legend: {
        data: ['销量']
      },
      xAxis: {
        type: 'category', //类目轴
        data: ['衬衫', '羊毛衫', '雪纺衫', '裤子', '高跟鞋', '袜子']
      },
      yAxis: {
        type: 'value' //数值轴
      },
      series: [
        {
          name: '销量',
          type: 'bar', //决定图表类型
          data: [5, 20, 36, 10, 10, 20],
          itemStyle: {
            // color: {
            //   type: 'linear',  // 线性渐变
            //   x: 0, 
            //   y: 0,
            //   x2: 0,
            //   y2: 1, 
            //   colorStops: [
            //     {
            //       offset: 0, color: 'red' // 0%处的颜色为蓝色
            //     },
            //     {
            //       offset: 1, color: 'blue' // 100%处的颜色为红色
            //     }
            //   ]

            // }
            color: {
              type: 'radial', //
              x: 0.5,
              y: 0.5,
              r: 0.5,
              colorStops: [
                {
                  offset: 0, color: 'red' // 0%处的颜色为蓝色
                },
                {
                  offset: 1, color: 'blue' // 100%处的颜色为红色
                }
              ],
              global: false // 缺省为 fals
            }

          }
        }
      ]
    }
    myCharts.setOption(option)
  </script>
</body>

</html>